/*
 * Copyright (C) 2007-2008  Hylke van der Schaaf
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, in version 3 of the License.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package hextd.core;

import com.twolattes.json.Entity;
import com.twolattes.json.Value;
import hextd.tower.JsonTower;
import hextd.tower.JsonTowerOptions;
import hextd.tower.TowerFactory.type;
import hextd.wave.PathNormal;
import hextd.wave.Wave;
import java.util.ArrayList;
import java.util.List;

@Entity
public class GameMap {

	private boolean initialised = false;
	@Value
	public String title = "noName";
	@Value(optional = true)
	public String info = "" +
			"Author: <b>The Unknown Mapper</b>";
	@Value(optional = true)
	public String story = "";
	@Value(optional = true)
	public String storyWin = "";
	@Value(optional = true)
	public String storyLos = "";
	@Value(optional = true)
	public String backGroundImage = "";
	@Value(optional = true)
	public int budget = 300;
	@Value(optional = true)
	public int interestStart = 3;
	@Value(optional = true)
	public int interestIncrease = 3;
	@Value(optional = true)
	public int lives = 20;
	@Value(optional = true)
	public int orientation = 0;
	@Value
	public List<String> gridData;
	@Value(optional = true)
	public List<JsonTower> towers;
	@Value
	public List<PathNormal> paths;
	@Value
	public List<Wave> waves;
	@Value(optional = true)
	public List<type> notTowers;
	@Value(optional = true)
	public List<JsonTowerOptions> towerOptions;

	public void initialise() {
		if (waves == null) {
			waves = new ArrayList<Wave>();
		}
		if (paths == null) {
			paths = new ArrayList<PathNormal>();
		}
		int level = 1;
		for (Wave wave : waves) {
			wave.setLevel(level++);
		}
		initialised = true;
	}

	public int getBudget() {
		return budget;
	}

	public List<String> getGridData() {
		if (gridData == null) {
			gridData = new ArrayList<String>();
		}
		return gridData;
	}

	public List<PathNormal> getPaths() {
		if (paths == null) {
			paths = new ArrayList<PathNormal>();
		}
		return paths;
	}

	public List<Wave> getWaves() {
		if (!initialised) {
			initialise();
		}
		return waves;
	}

	public List<JsonTower> getTowers() {
		if (towers == null) {
			towers = new ArrayList<JsonTower>();
		}
		return towers;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getTitle() {
		return title;
	}

	public void setInfo(String info) {
		this.info = info;
	}

	public String getInfo() {
		return info;
	}

	public void setBackGroundImage(String backGroundImage) {
		this.backGroundImage = backGroundImage;
	}

	public String getBackGroundImage() {
		return backGroundImage;
	}

	public void setBudget(int budget) {
		this.budget = budget;
	}

	public int getInterestStart() {
		return interestStart;
	}

	public void setInterestStart(int interestStart) {
		this.interestStart = interestStart;
	}

	public int getInterestIncrease() {
		return interestIncrease;
	}

	public void setInterestIncrease(int interestIncrease) {
		this.interestIncrease = interestIncrease;
	}

	public int getLives() {
		return lives;
	}

	public void setLives(int lives) {
		this.lives = lives;
	}

	public List<JsonTowerOptions> getTowerOptions() {
		return towerOptions;
	}

	public void setTowerOptions(List<JsonTowerOptions> towerOptions) {
		this.towerOptions = towerOptions;
	}

}
